package org.example.code.test2024.ten_mouth;

import java.util.*;

public class test1008 {
    public int[][] kClosest(int[][] points, int k) {

        Arrays.sort(points, new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                return ((o1[0]*o1[0]+o1[1]*o1[1])-(o2[0]*o2[0]+o2[1]*o2[1]));
            }
        });
        return Arrays.copyOfRange(points,0,k);

    }

    public int findMinFibonacciNumbers(int k) {
        List<Integer> list = new ArrayList<>();
        int a=1;
        int b=1;
        while(a+b<=k){
            int c=a+b;
            list.add(c);
            a=b;
            b=c;
        }
        int sum = 0;
        for(int i=list.size()-1;i>=0&&k>0;i--){
            int t = list.get(i);
            if(k>=t){
                sum++;
                k=k-t;
            }
        }
        return sum;
    }
}
